extern crate core;

use std::io::{Read, Write};
use std::net::{TcpListener, TcpStream};
use std::thread;
use chrono::Local;
use rand::random;
use rustracing::tag::Tag;
use serde_json::json;
use tokio::runtime::Runtime;
use crate::bound::inbound::InBoundServer;
use crate::bound::inbound_async::AsyncInboundServer;
use crate::client::TcpClient;
use crate::codes::http::{Response, ResponseData};
use crate::flags::SidecarConfig;
use crate::hystrix::rolling::rolling::Number;
use crate::mesh::MeshClient;
use crate::trace::jaeger::{JaegerTracing, ResponseTracing};

pub mod flags;
pub mod client;
mod codes;
mod queue;
mod mesh;
mod resource;
mod bound;
mod trace;
mod sidecar;
mod hystrix;
mod util;

fn main() {
    let config = SidecarConfig::new_from_arg();
    let mesh = MeshClient::new(config);
    mesh.run();
    // let rt = Runtime::new().unwrap();
    // let local_tasks = tokio::task::LocalSet::new();
    // local_tasks.spawn_local(async {
    //     let mut tt = AsyncInboundServer::new(8888,None).await;
    //     tt.run().await.expect("TODO: panic message");
    // });
    //
    // rt.block_on(local_tasks);
}


// fn main () {
//     let mut client = TcpClient::new(5555);
//     client.add_fn(String::from("test"),|_| ->Vec<u8> {
//         let data = Local::now().timestamp().to_string().into_bytes();
//         return data;
//     }) ;
//     client.run();
// }
